//
//  GDBusStationLineController.m
//  GraduationDesign
//
//  Created by JiaKang.Zhong on 16/1/5.
//  Copyright © 2016年 JiaKang.Zhong. All rights reserved.
//

#import "GDBusStationLineController.h"
#import "GDBusStationNumberController.h"
#import "GDTansitionModelDateOperation.h"
@interface GDBusStationLineController ()

@property(nonatomic,weak) UITextField * lineNumber;
@end

@implementation GDBusStationLineController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self setUpBusStationLineUI];
    

}


-(void) setUpBusStationLineUI{
 
 
    
    // 线路号:*
    UILabel * lineBus = [[UILabel alloc] initWithFrame:CGRectMake(GDScreenSize.size.width * 0.1, GDScreenSize.size.height * 0.1, 150, 30)];
    lineBus.text = @"线路号:*";
    [self.view addSubview:lineBus];
    
    // 请输入线路号,如:204
    UITextField * lineNumber = [[UITextField alloc] initWithFrame:CGRectMake(GDScreenSize.size.width*0.5 - 125, CGRectGetMaxY(lineBus.frame) + 20, 250, 40)];
    lineNumber.borderStyle = UITextBorderStyleRoundedRect;
    lineNumber.placeholder = @"请输入线路号,如:204";
    lineNumber.clearButtonMode = UITextFieldViewModeWhileEditing;
    [self.view addSubview:lineNumber];
    _lineNumber = lineNumber;
    
    // 查询按钮
    UIButton * searchBtn = [[UIButton alloc] initWithFrame:CGRectMake(20, CGRectGetMaxY(lineNumber.frame) + 20, GDScreenSize.size.width - 40, 40)];
    ;
    [searchBtn setTitle:@"查询" forState:UIControlStateNormal];
    [searchBtn setTintColor:[UIColor redColor]];
    [self.view addSubview:searchBtn];
    searchBtn.backgroundColor = [UIColor redColor];
    [searchBtn addTarget:self action:@selector(serachBtnClick) forControlEvents:UIControlEventTouchDown];
    
}



-(void) serachBtnClick{
    
    if (self.lineNumber.text.length == 0 || [self.lineNumber.text isEqualToString:@""]) {
        UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@"警告" message:@"请输入正确的公交路线" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [alertView show];
        return;
    }
    UIBarButtonItem * backItem = [[UIBarButtonItem alloc] init];
    backItem.title = @"返回上一级";
    self.navigationItem.backBarButtonItem = backItem;
    GDBusStationNumberController * stationNumberController = [[GDBusStationNumberController alloc] init];
    stationNumberController.busLineNumber = self.lineNumber.text;
    [self.navigationController pushViewController:stationNumberController animated:YES];
    
}


@end
